<?php
declare (strict_types = 1);

namespace app\event;

use app\listener\pay\PaySuccessByPaylog;
use app\model\CouponOrder;
use app\model\PayLog;
use think\Exception;

class OrderRefundSuccess
{

    public function __construct(CouponOrder $couponOrder)
    {
        //全款退
        $amount = $couponOrder->pay_amount;

        $couponOrder->payLog->status = PayLog::STATUS_REFUND;
        $couponOrder->payLog->refund_amount = $amount;
        $couponOrder->payLog->save();

        $couponOrder->refund_status = CouponOrder::C_REFUND_STATUS_HAVE;
        $couponOrder->status = CouponOrder::C_STATUS_RECHARGE_FAIL;
        $couponOrder->refund_amount = $amount;
        $couponOrder->agent_settle_status = CouponOrder::C_AGENT_SETTLE_STATUS_NO;
        $couponOrder->log.= date('Y-m-d H:i:s').'退款成功';
        $couponOrder->save();

    }
}
